<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>职工档案管理系统</title>
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <link rel="stylesheet" href="css/bootstrap.min.css">
  <link rel="stylesheet" href="css/font-awesome.min.css">
  <link rel="stylesheet" href="css/ionicons.min.css">
  <link rel="stylesheet" href="css/skin-blue.min.css">

  <!-- jQuery 3 -->
  <script src="js/jquery.min.js"></script>
  <!-- Bootstrap 3.3.7 -->
  <script src="js/bootstrap.min.js"></script>
  <!-- AdminLTE App -->
  <script src="js/adminlte.min.js"></script>

</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

  <div class="content-wrapper">
      <section class="content-header" style="text-align: center">
        <h1>
          新增职工档案
        </h1>
      </section>
    <section class="content container-fluid">
	<div class="box box-info">
            <form class="form-horizontal">
              <div class="box-body">
                <div class="form-group">
                  <label class="col-sm-2 control-label">姓名</label>
                  <div class="col-sm-10">
                    <input type="text" class="form-control" id="name" name="name" >
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-2 control-label">性别</label>
                  <div class="col-sm-10">
                    <input type="text" class="form-control" id="sex" name="sex">
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-2 control-label">年龄</label>
                  <div class="col-sm-10">
                    <input type="text" class="form-control" id="age" name="age">
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-2 control-label">学历</label>
                  <div class="col-sm-10">
                    <input type="text" class="form-control" id="education" name="education">
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-2 control-label">地址</label>
                  <div class="col-sm-10">
                    <input type="text" class="form-control" id="address" name="address">
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-2 control-label">电话</label>
                  <div class="col-sm-10">
                    <input type="text" class="form-control" id="phone" name="phone">
                  </div>
                </div>
              </div>
              <!-- /.box-body -->
              <div class="box-footer" style="text-align: center">
                <input type="button" onclick="tijiao()" class="btn btn-info" style="display:inline-block;margin:0 auto" value="提交"/>
              </div>
              <!-- /.box-footer -->
            </form>
          </div>
          <script type="text/javascript">
          	function tijiao() {
          		var name = $("#name").val();
          		var sex = $("#sex").val();
          		var age = $("#age").val();
          		var education = $("#education").val();
          		var address = $("#address").val();
          		var phone = $("#phone").val();
          		if(name=='' ){
          			alert("请输入姓名");
          			return;
          		}
                if(sex=='' ){
                  alert("请输入性别");
                  return;
                }
                if(age=='' ){
                  alert("请输入年龄");
                  return;
                }
                if(education=='' ){
                  alert("请输入学历");
                  return;
                }
                if(address=='' ){
                  alert("请输入地址");
                  return;
                }
                if(phone=='' ){
                  alert("请输入电话");
                  return;
                }
       			$.ajax({
       	            url : "users/addWorkers",
       	            type : "post",
       	            async : false,
       	            data : {
       	            	"name":name,
       	            	"sex":sex,
       	            	"age":age,
       	            	"education":education,
       	            	"address":address,
       	            	"phone":phone
       	            	},
       	            cache : false,
       	            dataType : "json",
       	            success : function(obj) {
                      if(obj.state==1){
                        window.location.href='list.html'
                      }else{
                        alert("新增失败，数据库出错，请联系管理员");
                      }
       	            }
       	        });
			}
          </script>
    </section>
  </div>
</div>

</body>
</html>